// 杜教筛
// 测试链接 ：https://www.luogu.com.cn/problem/P4213
// 相关帖子 ：https://www.cnblogs.com/dx123/p/16995109.html
// 相关帖子 ：https://oi-wiki.org/math/number-theory/du/
// 提交以下的code，可以直接通过

#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int MAXN = 2000010;
bool visited[MAXN];
ll cnt;
ll prime[MAXN], mu[MAXN], phi[MAXN];
unordered_map<ll, ll> muMap, phiMap;

void init()
{
    mu[1] = phi[1] = 1;
    for(int i = 2; i < MAXN; ++i)
    {
        if(!visited[i])
        {
            prime[++cnt] = i;
            mu[i] = -1;
            phi[i] = i - 1;
        }
        for(int j = 1; i * prime[j] < MAXN; ++j)
        {
            int p = prime[j];
            visited[i * p] = true;
            if(i % p == 0)
            {
                phi[i * p] = p * phi[i];
                break;
            }
            mu[i * p] = -mu[i];
            phi[i * p] = phi[i] * (p - 1);
        }
    }
    for(int i = 1; i < MAXN; ++i)
    {
        mu[i] += mu[i - 1];
        phi[i] += phi[i - 1];
    }
}

ll phiSum(ll n)
{
    if(n < MAXN) return phi[n]; // 预处理的剪枝
    if(phiMap[n]) return phiMap[n]; // 记忆化剪枝
    ll ans = n * (n + 1) / 2;
    for(ll l = 2, r; l <= n; l = r + 1)
    {
        r = n / (n / l);
        ans -= phiSum(n / l) * (r - l + 1);
    }
    return phiMap[n] = ans;
}

ll muSum(ll n)
{
    if(n < MAXN) return mu[n];
    if(muMap[n]) return muMap[n];
    ll ans = 1;
    for(ll l = 2, r; l <= n; l = r + 1)
    {
        r = n / (n / l);
        ans -= muSum(n / l) * (r - l + 1);
    }
    return muMap[n] = ans;
}

int main()
{
    init();
    ll t, n;
    scanf("%lld", &t);
    while(t--)
    {
        scanf("%lld", &n);
        printf("%lld %lld\n", phiSum(n), muSum(n));
    }

    return 0;
}